package com.lcc.ioc.demos.web.controller;

import com.lcc.ioc.demos.web.model.DBType;
import com.lcc.ioc.demos.web.model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;

@RestController
public class YmlController {
    @Value("${demo.key1}")//@Value将之定义的配置数据注入进来
    public String key1;
    @Value("${demo.key2}")
    public String key2;
    @Value("${demo.key3}")
    public Integer key3;

    @RequestMapping("/readYml")
    public String readYml(){
        return "key1:"+key1;
    }
    @Autowired
    private Student student;
    @Autowired
    private DBType dbType;
    @PostConstruct
    public void init(){
//        System.out.println("key1:"+key1);
//        System.out.println("key2:"+key2);
//        System.out.println("key3："+key3);
        System.out.println("student:"+student);
        System.out.println("dbType:"+dbType+"dbType的长度："+dbType.getName().length);
    }
}
